package com.rizzo.analytics.services.repo;

import com.rizzo.analytics.domain.account.Account;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface AccountRepository extends PagingAndSortingRepository<Account, Long>, JpaSpecificationExecutor {

    public Account findByUsername(@Param("username") String username);

    public Account findByEmail(@Param("email") String email);

    public List<Account> findByUsernameContainingIgnoreCase(@Param("username") String username, Pageable pageable);

    public List<Account> findByEmailContainingIgnoreCase(@Param("email") String email, Pageable pageable);

    public List<Account> findByFirstnameContainingIgnoreCase(@Param("firstname") String firstname, Pageable pageable);

    public List<Account> findByLastnameContainingIgnoreCase(@Param("lastname") String lastname, Pageable pageable);

    public List<Account> findByLockedTrue(Pageable pageable);

    public List<Account> findByExpiredTrue(Pageable pageable);

    public List<Account> findByDisabledTrue(Pageable pageable);

    public List<Account> findByLockedTrueOrExpiredTrueOrDisabledTrue(Pageable pageable);

    public List<Account> findByRolesContainingIgnoreCase(@Param("roles") String roles, Pageable pageable);

}